<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
		<title>数据还原</title>
		<link rel="stylesheet" href="/static/web/css/font-awesome.min.css">
		<link rel="stylesheet" href="/static/web/css/bootstrap.min.css">
		<link rel="stylesheet" href="/static/web/css/admin.css">
	</head>
	<body>
		<div class="container-fluid">
			<ol class="breadcrumb">
				<li class="breadcrumb-item"><a href="index_body.php">后台面板</a></li>
				<li class="breadcrumb-item"><a href="sys_data.php">数据备份</a></li>
				<li class="breadcrumb-item active">数据还原</li>
			</ol>
			<div class="card shadow-sm mb-3">
				<div class="card-body">
					<a href="sys_data.php" class="btn btn-success btn-sm">数据备份</a>
					<a href="sys_sql_query.php" class="btn btn-success btn-sm">SQL命令工具</a>
				</div>
			</div>
			<div class="card shadow-sm">
				<div class="card-header">数据还原</div>
				<div class="card-body">
					<form name="form1" action="sys_data_done.php" method="post" target="stafrm" onSubmit="checkSubmit();">
						<input type="hidden" name="dopost" value="redat">
						<input type="hidden" name="bakfiles">
						<div class="table-responsive">
							<table class="table table-borderless">
								<tbody>
									<?php
									for ($i=0;$i<count($filelists);$i++)
									{
										echo "<tr>";
										$mtd = "<td><input name='bakfile' id='bakfile' type='checkbox' value='".$filelists[$i]."' checked></td><td>{$filelists[$i]}</td>";
										echo $mtd;
										if (isset($filelists[$i+1])) {
											$i++;
											$mtd = "<td><input name='bakfile' id='bakfile' type='checkbox' value='".$filelists[$i]."' checked></td><td>{$filelists[$i]}</td>";
											echo $mtd;
										} else {
											echo "<td></td><td></td>";
										}
										echo "</tr>";
									}
									?>
									<tr>
										<td colspan="4">
											<label><input name="structfile" type="checkbox" id="structfile" value="<?php echo $structfile?>" checked> 还原数据表结构信息（<?php echo $structfile?>）</label>
											<label><input name="delfile" type="checkbox" id="delfile" value="1"> 还原后删除备份文件</label>
											<a href="javascript:SelAll();" class="btn btn-success btn-sm">全选</a>
											<a href="javascript:ReSel();" class="btn btn-success btn-sm">反选</a>
											<a href="javascript:NoneSel();" class="btn btn-success btn-sm">取消</a>
											<button type="submit"class="btn btn-success btn-sm">还原</button>
										</td>
									</tr>
									<tr>
										<td colspan="4">
											<div class="admin-win-iframe"><iframe name="stafrm" frameborder="0" id="stafrm" width="100%" height="100%"></iframe></div>
										</td>
									</tr>
								</tbody>
							</table>
						</div>
					</form>
				</div>
			</div>
		</div>
		<script>
			//获得选中文件的数据表
			function getCheckboxItem() {
				var myform = document.form1;
				var allSel = '';
				if (myform.bakfile.value) return myform.bakfile.value;
				for (i = 0; i < myform.bakfile.length; i++) {
					if (myform.bakfile[i].checked) {
						if (allSel == "")
							allSel = myform.bakfile[i].value;
						else
							allSel = allSel + "," + myform.bakfile[i].value;
					}
				}
				return allSel;
			}
			//反选
			function ReSel() {
				var myform = document.form1;
				for (i = 0; i < myform.bakfile.length; i++) {
					if (myform.bakfile[i].checked) myform.bakfile[i].checked = false;
					else myform.bakfile[i].checked = true;
				}
			}
			//全选
			function SelAll() {
				var myform = document.form1;
				for (i = 0; i < myform.bakfile.length; i++) {
					myform.bakfile[i].checked = true;
				}
			}
			//取消
			function NoneSel() {
				var myform = document.form1;
				for (i = 0; i < myform.bakfile.length; i++) {
					myform.bakfile[i].checked = false;
				}
			}
			function checkSubmit() {
				var myform = document.form1;
				myform.bakfiles.value = getCheckboxItem();
				return true;
			}
		</script>
	</body>
</html>